package com.five.zhh.fiveinfive.handler;

import com.five.zhh.fiveinfive.common.ZhhResponse;
import com.five.zhh.fiveinfive.handler.ex.ZhhSystemException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 粥灰灰
 * 2025/1/30 14:39
 */
@RestController
@ControllerAdvice
public class ExceptionController {

    @ExceptionHandler(ZhhSystemException.class)
    public ZhhResponse<Void> zhhSystemException(ZhhSystemException e) {
        return ZhhResponse.failure(e.getMessage());
    }

    @ExceptionHandler(IllegalArgumentException.class)
    public ZhhResponse<Void> illegalArgumentException(IllegalArgumentException e) {
        return ZhhResponse.failure(e.getMessage());
    }
}
